package com.sh.data.engine.domain.normalization.modeldesign.model.model.enums;

import com.sh.data.engine.domain.normalization.modeldesign.model.model.domain.StorageDomain;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

public enum DMFieldTypeEnum {
    TINYINT("SMALLINT"),
    SMALLINT("SMALLINT"),
    INT("INT"),
    BIGINT("BIGINT"),

    FLOAT("FLOAT"),
    DOUBLE("DOUBLE"),
    DECIMAL("DECIMAL(20,10)"),

    TIMESTAMP("TIMESTAMP"),

    CHAR("CHAR(255)"),
    STRING("TEXT"),
    VARCHAR("VARCHAR(400)"),

    DATE("DATE"),
    BOOLEAN("BOOLEAN"),
    BINARY("BLOB");

    private final String dbFieldType;

    DMFieldTypeEnum(String dbFieldType) {
        this.dbFieldType = dbFieldType;
    }

    public String getDbFieldType() {
        return dbFieldType;
    }

    public static List<StorageDomain.FieldType> getAllFieldType() {
        DMFieldTypeEnum[] values = DMFieldTypeEnum.values();
        return Arrays.stream(values)
            .map(i -> new StorageDomain.FieldType(i.dbFieldType, i.name()))
            .collect(Collectors.toList());
    }

    public static List<String> getMdAllFieldType() {
        DMFieldTypeEnum[] values = DMFieldTypeEnum.values();
        return Arrays.stream(values).map(i -> i.dbFieldType).collect(Collectors.toList());
    }
}
